"""
xml转json
"""
import xmltodict
import json

with open("./XMLSession.chlsx", 'r', encoding='utf-8') as f:
    text = f.read()
    xml_parse=xmltodict.parse(text)
    json_str = json.dumps(xml_parse, indent=1)
    # print('json_str:',json_str)
    # xml转成dict后有些key前面会带有 @ 字符，去除
    json_str =str(json_str)
    json_str =json_str.replace('\"@','\"')
    print('json_str:',json_str)
    json_dict=json.loads(json_str)
    transaction=json_dict['charles-session']['transaction']
    # print('transaction:', transaction)
